﻿using System;

namespace Program25
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nums = new int[] { 1, 3, 5, 7, 9, 11, 13, 15, 17 };
            int max = 0;
            int min = 0;
            int sum = 0;
            int avg = 0;
            Group(nums, out max, out min, out sum, out avg);
            Console.WriteLine("最大值{0}，最小值{1}，平均值{2}，总和{3}", max, min, sum, avg);
        }
        //求一个数组最大值，最小值，平均值，总和

        public static void Group(int[] nums, out int max, out int min, out int avg, out int sum)
        {
            max = nums[0];
            min = nums[0];
            sum = 0;
            avg = 0;

            for (int i = 0; i < nums.Length; i++)
            {
                if (nums[i] > max)
                {
                    max = nums[i];
                }
                if (nums[i] < min)
                {
                    min = nums[i];
                }
                sum += nums[i];
            }
            avg = sum / nums.Length;
        }
    }
}
